﻿@model FlashCards.WebApp.Models.AdminModel
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
@if (Model != null)
{
    <h3>
        Categories</h3>
    
    <table>
        <tr>
            <th>
                Id
            </th>
            <th>
                Name
            </th>
            <th>
                Parent id
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.Categories)
        {
            <tr>
                <td>
                    @Html.DisplayFor(x => item.Id)
                </td>
                <td>
                    @Html.DisplayFor(x => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(x => item.ParentId)
                </td>
                <td>
                    @Html.ActionLink("delete", "DeleteCategory", new { categoryId = item.Id })
                </td>
            </tr>
        }
    </table>
    
    @Html.ActionLink("Add category", "AddCategory", "Admin")
    
    <table>
        <tr>
            <th>user</th>
            <th>last login</th>
        </tr>
        @foreach (var item in Model.Users)
        {
            <tr>
                <td>
                    @item.Name @item.Surname
                </td>
                <td>
                    @Html.DisplayFor(x => item.LastLoginDate)
                </td>
            </tr>
        }
    </table>
    
    

        using (Html.BeginForm("AddNews", "Admin"))
        { 
        <h3>
            NEWS</h3>
        <span>Title</span>
        @Html.TextBox("NewsTitle")
        <span>Message</span>
        @Html.TextBox("NewsMessage")

        <input type="submit" runat="server" value="add news" />
    }
}